package com.jctrip.hotel.management.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jctrip.hotel.management.model.param.*;
import com.jctrip.hotel.management.model.result.GetAllPricePolicyResult;
import com.jctrip.hotel.management.model.result.GetFeizhuPricePolicyResult;
import com.jctrip.hotel.management.model.result.GetXieChengPricePolicyResult;
import com.jctrip.hotel.management.model.result.Result;
import com.jctrip.hotel.management.service.PricePolicyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.cert.ocsp.Req;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "management-pricePolicy")
@RestController
@RequestMapping("/management/pricePolicy")
public class PricePolicyController {
    @Autowired
    private PricePolicyService pricePolicyService;

    @PostMapping("/listAllPricePolicy")
    @ApiOperation(value = "listAllPricePolicy", notes = "获取价格政策列表")
    @ApiOperationSupport(order = 1)
    public Result<GetAllPricePolicyResult> listAllPricePolicy(@RequestBody GetAllPricePolicyParam param) {
        return Result.ok(pricePolicyService.listAllPricePolicy(param));
    }

    @PostMapping("/editPricePolicy")
    @ApiOperation(value = "editPricePolicy", notes = "修改价格政策")
    @ApiOperationSupport(order = 2)
    public Result<Boolean> editPricePolicy(@RequestBody UpdatePricePolicyParam param) {
        return Result.ok(pricePolicyService.editPricePolicy(param));
    }

    @GetMapping("/getFeizhuPricePolicy")
    @ApiOperation(value = "获取飞猪的价格政策", notes = "获取飞猪的价格政策")
    @ApiOperationSupport(order = 3)
    public Result<GetFeizhuPricePolicyResult> getFeizhuPricePolicy(@RequestParam String routeId,
                                                                   @RequestParam(required = false, defaultValue = "1") Long pageNum,
                                                                   @RequestParam(required = false, defaultValue = "10") Long pageSize) {
        return pricePolicyService.getFeizhuPricePolicy(routeId, pageNum, pageSize);
    }

    @PostMapping("/insertFeizhuPricePolicy")
    @ApiOperation(value = "新增飞猪价格政策", notes = "新增飞猪价格政策")
    @ApiOperationSupport(order = 4)
    public Result<String> insertFeizhuPricePolicy(@RequestBody InsertFeizhuPricePolicyParam param) {
        return pricePolicyService.insertFliggyPricePolicy(param);
    }

    @PostMapping("/updateFeizhuPricePolicy")
    @ApiOperation(value = "修改飞猪价格政策", notes = "修改飞猪价格政策")
    @ApiOperationSupport(order = 5)
    public Result<String> updateFeizhuPricePolicy(@RequestBody UpdateFeizhuPricePolicyParam param) {
        return pricePolicyService.updateFliggyPricePolicy(param);
    }

    @PostMapping("/updateFeizhuPricePolicyRange")
    @ApiOperation(value = "修改飞猪加价率", notes = "修改飞猪加价率")
    @ApiOperationSupport(order = 6)
    public Result<String> updateFeizhuPricePolicyRange(@RequestBody UpdateFeizhuPricePolicyRangeParam param) {
        return pricePolicyService.updateFliggyPricePolicyRange(param);
    }

    @GetMapping("/getXieChengPricePolicy")
    @ApiOperation(value = "获取携程的价格政策", notes = "获取携程的价格政策")
    @ApiOperationSupport(order = 7)
    public Result<GetXieChengPricePolicyResult> getXieChengPricePolicy(@RequestParam String routeId,
                                                                       @RequestParam(required = false, defaultValue = "1") Long pageNum,
                                                                       @RequestParam(required = false, defaultValue = "10") Long pageSize) {
        return pricePolicyService.getXieChengPricePolicy(routeId, pageNum, pageSize);
    }

    @PostMapping("/updateXiechengPricePolicy")
    @ApiOperation(value = "修改携程价格政策", notes = "修改携程价格政策")
    @ApiOperationSupport(order = 8)
    public Result<String> updateXiechengPricePolicy(@RequestBody UpdateXiechengPricePolicyParam updateXiechengPricePolicyParam) {
        return pricePolicyService.updateXiechengPricePolicy(updateXiechengPricePolicyParam);
    }

    @PostMapping("/updateXiechengPricePolicyRange")
    @ApiOperation(value = "修改携程加价率", notes = "修改携程加价率")
    @ApiOperationSupport(order = 9)
    public Result<String> updateXiechengPricePolicyRange(@RequestBody UpdateXiechengPricePolicyRangeParam updateXiechengPricePolicyRangeParam) {
        return pricePolicyService.updateXiechengPricePolicyRange(updateXiechengPricePolicyRangeParam);
    }
}
